home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9391 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: unsigned char question
  5. Date: Fri, 01 Mar 1996 16:34:18 +0200
  6. Organization: Carelcomp Forest
  7. Message-ID: <31370AEA.75E@cmt.lpr.mail.carel.fi>
  8. References: <3136864B.7154@eds.com>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Perry Hoekstra wrote:
  16. > This is a basic question but one I cannot answer.  I am using VC++ 2.0
  17. > and I wish to assign a string to a variable of type UCHAR * (which is an unsigned
  18. > char within ODBC).  The code is as follows
  19. > UCHAR * server;
  20. > server = "jmbademo";
  21. > When I attempt to compile this piece of code, I receive the following error:
  22. > C:\cgi\Envvars\Envvar.cpp(417) : error C2446: '=' : no conversion from 'char[9]'
  23. > to 'unsigned char*'
  24. > In addition, when I try to copy or concatenate with lstrcpy or lstrcat, I receive
  25. > the following error:
  26. > C:\cgi\Envvars\Envvar.cpp(432) : error C2664: 'lstrcpyA' : cannot convert
  27. > parameter 1 from 'unsigned char*' to 'char*'
  28. > C:\cgi\Envvars\Envvar.cpp(433) : error C2664: 'lstrcatA' : cannot convert
  29. > parameter 1 from 'unsigned char*' to 'char*'
  30. > I am taking these code examples straight from Microsoft's examples for ODBC
  31. > calls in their MSDN CD-ROM (i.e. Static SQL Example).  What am I doing wrong or
  32. > how would you code a SQLConnect call within VC++ 2.0?
  33. > Thank you
  34.  
  35. Just cast the parameters, for example:
  36.  
  37.     server = (UCHAR *)"jmbademo";
  38.  
  39. I know, it's ugly, but MSVC tends to be a little too picky on parameter type 
  40. checking... However, when you explicitly do the cast, the compiler is happy :)
  41.  
  42. Later,
  43.  AriL
  44. -- 
  45. All my opinions are mine and mine alone.
  46.